The example below determines sub-types of a given data type:
// This example shows how to retrieve all sub-types of a given data type, recursively. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.BaseLib.OperationModel.Generic; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.AddressSpace.Standard; using OpcLabs.EasyOpc.UA.Extensions; namespace UADocExamples._EasyUAClient { class RetrieveAllDataTypes { public static void Main1() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object var client = new EasyUAClient(); // Retrieve all sub-types of the 'Structure' data type. ValueResult<UANodeDescriptor[]> result = client.RetrieveAllDataTypes( endpointDescriptor, UADataTypeIds.Structure); // Check if the operation succeeded. Use the ThrowIfFailed method instead if you want exception be thrown. if (!result.Succeeded) { Console.WriteLine("*** Failure: {0}", result.ErrorMessageBrief); return; } // Display results. Note that all node descriptors have node IDs in them; but the default display format shows // the browse paths, which are more readable, when they are available. foreach (UANodeDescriptor nodeDescriptor in result.Value) Console.WriteLine(nodeDescriptor); // Example output: // //NodeId="Structure" //BrowsePath="[Structure]/Argument" //BrowsePath="[Structure]/StatusResult" //BrowsePath="[Structure]/UserTokenPolicy" //BrowsePath="[Structure]/ApplicationDescription" //BrowsePath="[Structure]/EndpointDescription" //BrowsePath="[Structure]/UserIdentityToken" //BrowsePath="[Structure]/EndpointConfiguration" //BrowsePath="[Structure]/SupportedProfile" //BrowsePath="[Structure]/BuildInfo" //BrowsePath="[Structure]/SoftwareCertificate" //BrowsePath="[Structure]/SignedSoftwareCertificate" //BrowsePath="[Structure]/AddNodesItem" //BrowsePath="[Structure]/AddReferencesItem" //BrowsePath="[Structure]/DeleteNodesItem" //BrowsePath="[Structure]/DeleteReferencesItem" //BrowsePath="[Structure]/ScalarTestType" //BrowsePath="[Structure]/ArrayTestType" //BrowsePath="[Structure]/CompositeTestType" //BrowsePath="[Structure]/RegisteredServer" //BrowsePath="[Structure]/ContentFilterElement" //BrowsePath="[Structure]/ContentFilter" //BrowsePath="[Structure]/FilterOperand" //BrowsePath="[Structure]/HistoryEvent" //BrowsePath="[Structure]/MonitoringFilter" //BrowsePath="[Structure]/RedundantServerDataType" //BrowsePath="[Structure]/SamplingIntervalDiagnosticsDataType" //BrowsePath="[Structure]/ServerDiagnosticsSummaryDataType" //BrowsePath="[Structure]/ServerStatusDataType" //BrowsePath="[Structure]/SessionDiagnosticsDataType" //BrowsePath="[Structure]/SessionSecurityDiagnosticsDataType" //BrowsePath="[Structure]/ServiceCounterDataType" //BrowsePath="[Structure]/SubscriptionDiagnosticsDataType" //BrowsePath="[Structure]/ModelChangeStructureDataType" //BrowsePath="[Structure]/Range" //BrowsePath="[Structure]/EUInformation" //BrowsePath="[Structure]/Annotation" //BrowsePath="[Structure]/ProgramDiagnosticDataType" //BrowsePath="[Structure]/SemanticChangeStructureDataType" //BrowsePath="[Structure]/HistoryEventFieldList" //BrowsePath="[Structure]/AggregateConfiguration" //BrowsePath="[Structure]/EnumValueType" //BrowsePath="[Structure]/TimeZoneDataType" //BrowsePath="[Structure]/EndpointUrlListDataType" //BrowsePath="[Structure]/NetworkGroupDataType" //BrowsePath="[Structure]/AxisInformation" //BrowsePath="[Structure]/XVType" //BrowsePath="[Structure]/ComplexNumberType" //BrowsePath="[Structure]/DoubleComplexNumberType" //BrowsePath="[Structure]/ScalarValueDataType" //BrowsePath="[Structure]/ArrayValueDataType" //BrowsePath="[Structure]/UserScalarValueDataType" //BrowsePath="[Structure]/UserArrayValueDataType" //BrowsePath="[Structure]/UserIdentityToken/AnonymousIdentityToken" //BrowsePath="[Structure]/UserIdentityToken/UserNameIdentityToken" //BrowsePath="[Structure]/UserIdentityToken/X509IdentityToken" //BrowsePath="[Structure]/UserIdentityToken/IssuedIdentityToken" //BrowsePath="[Structure]/FilterOperand/ElementOperand" //BrowsePath="[Structure]/FilterOperand/LiteralOperand" //BrowsePath="[Structure]/FilterOperand/AttributeOperand" //BrowsePath="[Structure]/FilterOperand/SimpleAttributeOperand" //BrowsePath="[Structure]/MonitoringFilter/EventFilter" } } }
' This example shows how to retrieve all sub-types of a given data type, recursively. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.BaseLib.OperationModel.Generic Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.AddressSpace.Standard Imports OpcLabs.EasyOpc.UA.Extensions Namespace _EasyUAClient Friend Class RetrieveAllDataTypes Public Shared Sub Main1() Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Instantiate the client object Dim client = New EasyUAClient() ' Retrieve all sub-types of the 'Structure' data type. Dim result As ValueResult(Of UANodeDescriptor()) = client.RetrieveAllDataTypes( _ endpointDescriptor, UADataTypeIds.Structure) ' Check if the operation succeeded. Use the ThrowIfFailed method instead if you want exception be thrown. If Not result.Succeeded Then Console.WriteLine("*** Failure: {0}", result.ErrorMessageBrief) End If ' Display results. Note that all node descriptors have node IDs in them; but the default display format shows ' the browse paths, which are more readable, when they are available. For Each nodeDescriptor As UANodeDescriptor In result.Value Console.WriteLine(nodeDescriptor) Next nodeDescriptor ' Example output: ' 'NodeId="Structure" 'BrowsePath="[Structure]/Argument" 'BrowsePath="[Structure]/StatusResult" 'BrowsePath="[Structure]/UserTokenPolicy" 'BrowsePath="[Structure]/ApplicationDescription" 'BrowsePath="[Structure]/EndpointDescription" 'BrowsePath="[Structure]/UserIdentityToken" 'BrowsePath="[Structure]/EndpointConfiguration" 'BrowsePath="[Structure]/SupportedProfile" 'BrowsePath="[Structure]/BuildInfo" 'BrowsePath="[Structure]/SoftwareCertificate" 'BrowsePath="[Structure]/SignedSoftwareCertificate" 'BrowsePath="[Structure]/AddNodesItem" 'BrowsePath="[Structure]/AddReferencesItem" 'BrowsePath="[Structure]/DeleteNodesItem" 'BrowsePath="[Structure]/DeleteReferencesItem" 'BrowsePath="[Structure]/ScalarTestType" 'BrowsePath="[Structure]/ArrayTestType" 'BrowsePath="[Structure]/CompositeTestType" 'BrowsePath="[Structure]/RegisteredServer" 'BrowsePath="[Structure]/ContentFilterElement" 'BrowsePath="[Structure]/ContentFilter" 'BrowsePath="[Structure]/FilterOperand" 'BrowsePath="[Structure]/HistoryEvent" 'BrowsePath="[Structure]/MonitoringFilter" 'BrowsePath="[Structure]/RedundantServerDataType" 'BrowsePath="[Structure]/SamplingIntervalDiagnosticsDataType" 'BrowsePath="[Structure]/ServerDiagnosticsSummaryDataType" 'BrowsePath="[Structure]/ServerStatusDataType" 'BrowsePath="[Structure]/SessionDiagnosticsDataType" 'BrowsePath="[Structure]/SessionSecurityDiagnosticsDataType" 'BrowsePath="[Structure]/ServiceCounterDataType" 'BrowsePath="[Structure]/SubscriptionDiagnosticsDataType" 'BrowsePath="[Structure]/ModelChangeStructureDataType" 'BrowsePath="[Structure]/Range" 'BrowsePath="[Structure]/EUInformation" 'BrowsePath="[Structure]/Annotation" 'BrowsePath="[Structure]/ProgramDiagnosticDataType" 'BrowsePath="[Structure]/SemanticChangeStructureDataType" 'BrowsePath="[Structure]/HistoryEventFieldList" 'BrowsePath="[Structure]/AggregateConfiguration" 'BrowsePath="[Structure]/EnumValueType" 'BrowsePath="[Structure]/TimeZoneDataType" 'BrowsePath="[Structure]/EndpointUrlListDataType" 'BrowsePath="[Structure]/NetworkGroupDataType" 'BrowsePath="[Structure]/AxisInformation" 'BrowsePath="[Structure]/XVType" 'BrowsePath="[Structure]/ComplexNumberType" 'BrowsePath="[Structure]/DoubleComplexNumberType" 'BrowsePath="[Structure]/ScalarValueDataType" 'BrowsePath="[Structure]/ArrayValueDataType" 'BrowsePath="[Structure]/UserScalarValueDataType" 'BrowsePath="[Structure]/UserArrayValueDataType" 'BrowsePath="[Structure]/UserIdentityToken/AnonymousIdentityToken" 'BrowsePath="[Structure]/UserIdentityToken/UserNameIdentityToken" 'BrowsePath="[Structure]/UserIdentityToken/X509IdentityToken" 'BrowsePath="[Structure]/UserIdentityToken/IssuedIdentityToken" 'BrowsePath="[Structure]/FilterOperand/ElementOperand" 'BrowsePath="[Structure]/FilterOperand/LiteralOperand" 'BrowsePath="[Structure]/FilterOperand/AttributeOperand" 'BrowsePath="[Structure]/FilterOperand/SimpleAttributeOperand" 'BrowsePath="[Structure]/MonitoringFilter/EventFilter" End Sub End Class End Namespace
# This example shows how to retrieve all sub-types of a given data type, recursively. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.AddressSpace.Standard import * from OpcLabs.EasyOpc.UA.Extensions import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() # Retrieve all sub-types of the 'Structure' data type. valueResult = IEasyUAClientExtension2.RetrieveAllDataTypes(client, endpointDescriptor, UANodeDescriptor(UADataTypeIds.Structure)) # Check if the operation succeeded. Use the ThrowIfFailed method instead if you want exception be thrown. if not valueResult.Succeeded: print('*** Failure: ', valueResult.ErrorMessageBrief, sep='') exit() # Display results. Note that all node descriptors have node IDs in them; but the default display format shows # the browse paths, which are more readable, when they are available. for nodeDescriptor in valueResult.Value: print(nodeDescriptor) print() print('Finished.')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support